Skip to content

[Bug]: document.createElement is a Proxy #12589

Closed
@AntonPolyakin

Description

Minimal, reproducible example

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto('about:blank');

  const result = await page.evaluate(() => {
    return Object.getOwnPropertyNames(document).includes('createElement');
  });
  console.log(result); // Should log: false, but it shows true

  await browser.close();
})();

Error string

no error

Bug behavior

  • Flaky
    PDF

Background

document.createElement is an indicator of Puppeteer usage. This knowledge allows protected sites (e.g., Cloudflare: berstend/puppeteer-extra#832) to deny access not only to bots using Puppeteer but also to people who create a browser instance through Puppeteer.

A long time ago, this issue was already described, but it was ignored: #7402. Now, I want to revive the discussion on this topic. Solving it could potentially address access issues to a large number of resources.

Expectation

document.createElement should be a function exactly as described in the DOM Standard

Reality

document.createElement is now a proxy function, which is functionally no different from a normal function, but its use affects client security

Puppeteer configuration file (if used)

No response

Puppeteer version

22.11.0

Node version

18.16.1

Package manager

npm

Package manager version

9.5.1

Operating system

Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @AntonPolyakin

      Issue actions

        [Bug]: document.createElement is a Proxy · Issue #12589 · puppeteer/puppeteer